package com.yitongmao.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yitongmao.bean.TsAdapterBean;
import com.yitongmao.yitmfruit.R;

import java.util.List;

/*
* 作者：梁伟航 on 2017/8/11 18:18
* 类的用途：
*/
public class TSAdapter extends BaseAdapter{
    private Context context;
    private List<TsAdapterBean.RefundListBean> refundList;

    public TSAdapter(Context context, List<TsAdapterBean.RefundListBean> refundList) {
        this.context=context;
        this.refundList=refundList;
    }

    @Override
    public int getCount() {
        return refundList.size();
    }

    @Override
    public Object getItem(int position) {
        return refundList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.tuihuolistitem, null);
            //图片
            viewHolder.homelistimage = (ImageView) convertView.findViewById(R.id.homelistimage);
            //title
            viewHolder.homelistTitle = (TextView) convertView.findViewById(R.id.homelistTitle);
            viewHolder.Dingdanhao = (TextView) convertView.findViewById(R.id.mDingdanhao);
            viewHolder.mShenqingTime = (TextView) convertView.findViewById(R.id.mShenqingTime);
            viewHolder.mZhuangtai = (TextView) convertView.findViewById(R.id.mZhuangtai);
            viewHolder.mbody = (TextView) convertView.findViewById(R.id.mbody);
            convertView.setTag(viewHolder);//绑定ViewHolder对象
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mZhuangtai.setText(refundList.get(position).stateName);
        viewHolder.mShenqingTime.setText(refundList.get(position).createTime);
        viewHolder.Dingdanhao.setText(refundList.get(position).orderCode);
        Glide.with(context).load(refundList.get(position).orderGoods.get(0).goodsThumb).into(viewHolder.homelistimage);
        viewHolder.homelistTitle.setText(refundList.get(position).orderGoods.get(0).title);
        viewHolder.mbody.setText(refundList.get(0).describe);
        return convertView;
    }
    class ViewHolder {

        public TextView homelistTitle;
        public ImageView homelistimage;
        public TextView Dingdanhao;
        public TextView mShenqingTime;
        public TextView mZhuangtai;
        public TextView mbody;
    }
}
